home *** CD-ROM | disk | FTP | other *** search
/ E.M.Computergraphic Phase 4 / Phase 4 - Desktop Video Dreams (E. M. Computergraphic)(1996).iso / utilities / imagestudio / rexx / balancetest.isrx next >
Text File  |  1996-01-17  |  4KB  |  161 lines

  1. /* ImageStudio ARexx script **************************************/
  2.  
  3. /* Allow commands to return results */
  4.  
  5. options results
  6.  
  7. /* On error, goto ERROR:. Comment out this line if you wish to */
  8. /* perform your own error checking. */
  9.  
  10. signal on error
  11.  
  12. /* BEGIN PROGRAM *************************************************/
  13.  
  14. /* See if we have an image already */
  15.  
  16. IMAGEINFO_GET STEM imageinfo.
  17.  
  18. if imageinfo.changed == 1 then do
  19.     REQUEST_MESSAGE TEXT '"Project has changed, continue?"',
  20.         BUTTONTEXT '"OK|Cancel"' AUTOCANCEL
  21.  
  22.     end
  23. else if imageinfo.changed == -1 then do
  24.     /* Open a filerequester to get an image to operate on */
  25.  
  26.     REQUEST_FILE TITLE '"Choose image..."' VAR imagefile
  27.  
  28.     OPEN FILE '"'imagefile'"'
  29.  
  30.     /* Get the new image's details */
  31.  
  32.     IMAGEINFO_GET STEM 'imageinfo.'
  33.  
  34.     end
  35.  
  36. /* Get the number of steps across to perform */
  37.  
  38. REQUEST_MESSAGE TEXT '"Choose number of steps..."',
  39.     BUTTONTEXT '"3|5|7|9|15|Cancel"' AUTOCANCEL
  40.  
  41. /* Get the number of steps */
  42.  
  43. select
  44.     when result == 1 then
  45.         num_steps = 3
  46.     when result == 2 then
  47.         num_steps = 5
  48.     when result == 3 then
  49.         num_steps = 7
  50.     when result == 4 then
  51.         num_steps = 9
  52.     when result == 5 then
  53.         num_steps = 15
  54.     otherwise
  55.         nop
  56.     end
  57.  
  58. /* If the image is colour mapped, change it to 24bit */
  59.  
  60. if imageinfo.depth ~= 24 then
  61.     COLOURS SIXTEENMILLION
  62.  
  63. /* Perform the colour balance changes */
  64.  
  65. do y = 0 to 2
  66.     do x = 0 to (num_steps - 1)
  67.         /* Work out the region to select */
  68.  
  69.         left = (x * imageinfo.width) % num_steps
  70.         right = (((x + 1) * imageinfo.width) % num_steps) - 1
  71.  
  72.         top = (y * imageinfo.height) % 3
  73.         bottom = (((y + 1) * imageinfo.height) % 3) - 1
  74.  
  75.         REGION_SET left top TO right bottom
  76.  
  77.         /* Work out the value between -100 and +100 */
  78.  
  79.         balanceval = (200 * x) % (num_steps - 1)
  80.         balanceval = balanceval - 100
  81.  
  82.         /* Adjust the appropriate colour balance */
  83.  
  84.         select
  85.             when y == 0 then
  86.                 BALANCE BRIGHTNESS balanceval
  87.             when y == 1 then
  88.                 BALANCE CONTRAST balanceval
  89.             when y == 2 then
  90.                 BALANCE GAMMA balanceval
  91.             otherwise
  92.                 nop
  93.             end
  94.         end
  95.     end
  96.  
  97. /* Clear the region */
  98.  
  99. REGION_CLEAR
  100.  
  101. /* END PROGRAM ***************************************************/
  102.  
  103. exit
  104.  
  105. /* On ERROR */
  106.  
  107. ERROR:
  108.  
  109. /* If we get here, either an error occurred with the command's */
  110. /* execution or there was an error with the command itself. */
  111. /* In the former case, rc2 contains the error message and in */
  112. /* the latter, rc2 contains an error number. SIGL contains */
  113. /* the line number of the command which caused the jump */
  114. /* to ERROR: */
  115.  
  116. if datatype(rc2,'NUMERIC') == 1 then do
  117.     /* See if we can describe the error with a string */
  118.  
  119.     select
  120.         when rc2 == 103 then
  121.             err_string = "ERROR 103, "||,
  122.                 "out of memory at line "||SIGL
  123.         when rc2 == 114 then
  124.             err_string = "ERROR 114, "||,
  125.                 "bad command template at line "||SIGL
  126.         when rc2 == 115 then
  127.             err_string = "ERROR 115, "||,
  128.                 "bad number for /N argument at line "||SIGL
  129.         when rc2 == 116 then
  130.             err_string = "ERROR 116, "||,
  131.                 "required argument missing at line "||SIGL
  132.         when rc2 == 117 then
  133.             err_string = "ERROR 117, "||,
  134.                 "value after keywork missing at line "||SIGL
  135.         when rc2 == 118 then
  136.             err_string = "ERROR 118, "||,
  137.                 "wrong number of arguments at line "||SIGL
  138.         when rc2 == 119 then
  139.             err_string = "ERROR 119, "||,
  140.                 "unmatched quotes at line "||SIGL
  141.         when rc2 == 120 then
  142.             err_string = "ERROR 120, "||,
  143.                 "line too long at line "||SIGL
  144.         when rc2 == 236 then
  145.             err_string = "ERROR 236, "||,
  146.                 "unknown command at line "||SIGL
  147.         otherwise
  148.             err_string = "ERROR "||rc2||", at line "||SIGL
  149.         end
  150.         end
  151. else if rc2 == 'RC2' then do
  152.     err_string = "ERROR in command at line "||SIGL
  153.     end
  154. else do
  155.         err_string = rc2||", line "||SIGL
  156.         end
  157.  
  158. request_message TEXT '"'err_string'"'
  159.  
  160. exit
  161.